package org.sanguine.study.hometasks.first.task.a;

import org.sanguine.study.hometasks.first.Runner;

public class TaskA7 extends CommonWordTask {
	private String theMostComplexWord = "";

	public static void main(String[] args) {
		Runner runner = new TaskA7();
		runner.run(args);
	}

	@Override
	public void doTask() {
		if (in == null || out == null || numberOfItems <= 0) return;
		readItems();
		if (items != null) findTheMostComplexWord();
		printResult();
	}

	private void findTheMostComplexWord() {

		if (items.length == 0) return;
		
		theMostComplexWord = items[0];
		
		for (int i = 1; i < items.length; i++) {
			if (items[i].length() == countDifferentChars(items[i])) {
				theMostComplexWord = items[i];
				return;
			}
		}
	}

	private void printResult() {
		if (theMostComplexWord == null) out.println("Word not found");
		else out.printf("Found word: %s\n", theMostComplexWord);
	}

}
